﻿<%@ Page Title="" Language="C#" 
    ValidateRequest="False" 
    MasterPageFile="/Medianamik/MasterPages/MedianamikModule.Master" 
    AutoEventWireup="True" CodeBehind="ListManagement.aspx.cs" 
    Inherits="Medianamik.UI.Web.ContentManagement.ListManagement" %>
<%@ Import Namespace="Medianamik.Core" %>
<%@ Register TagPrefix="med" Namespace="Medianamik.UI.Controls" %>

<asp:Content ID="ContextMenuContent" ContentPlaceHolderID="ContextMenu" runat="server">
    <asp:LinkButton ID="btnSave" runat="server" Text="<%$ Resources: Medianamik_Global, SaveButtonText %>" CssClass="Action BtSauvegarder SuspendLock" OnClick="Save" />
    <asp:HyperLink ID="lnkCancel" runat="server" Text="<%$ Resources: Medianamik_Global, Cancel %>" CssClass="Action BtAnnuler unlock" />
</asp:Content>

<asp:Content ID="CenterContent" ContentPlaceHolderID="CenterContent" runat="server">
    <asp:ScriptManagerProxy ID="scriptManagerProxy" runat="server" OnNavigate="OnNavigate">
        <Services>
            <asp:ServiceReference Path="/Medianamik/Services/LockWebService.asmx" />
        </Services>
    </asp:ScriptManagerProxy>
    <asp:UpdatePanel ID="breadcrumbUpdatePanel" runat="server" UpdateMode="Conditional"
        ChildrenAsTriggers="true">
        <ContentTemplate>
            <med:BreadcrumbTrail ID="bctFilAriane" 
                                 PostBackClientEvent="breadcrumbClick" 
                                 runat="server" 
                                 CssClass="FilAriane" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="uptPanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <lock:LockInfoTooltip runat="server" ID="LockInfoTooltip" OnLockDeleted="LockInfoTooltip_LockDeleted" />
            <med:MedianamikFormTemplate ID="MedFormTemplate" runat="server" DefaultCultureName="en-ca" />
            <asp:HiddenField ID="lockResquestFailed" runat="server" Value="" />
            <asp:HiddenField ID="backOrForward" runat="server" Value="" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

<asp:Content ID="ExternalContent" ContentPlaceHolderID="ExternalContentHolder" runat="server">
    <telerik:RadScriptBlock runat="server" ID="scriptBlock">
        <script type="text/javascript">
            //<![CDATA[
            function confirmLeaveEdition(typeid) 
            {
                if (confirm('<%= Translator.TranslateJS("Medianamik_ContentManagement", "LeaveEditionMessage") %>')) {
                    $find('<%= MedianamikFormTemplate.LockActivator.ClientID %>').set_lockStopped(true);
                    Medianamik.UI.Services.LockWebService.Unlock(nodeId);
                    var returnURL = '<%= ReturnURL %>';
                    if (typeid)
                        returnURL += '?<%= DefaultParamNames.TypeID %>=' + typeid;
                    window.location = returnURL;
                }
            }

            function breadcrumbClick(clientid, id) 
            {
                if (id == '<%= RootNodeId.ToString() %>') {
                    confirmLeaveEdition(id);
                }
                else if (confirm('<%= Translator.TranslateJS("Medianamik_ContentManagement", "SwitchNodeEditionMessage") %>')) {
                    $find('<%= MedianamikFormTemplate.LockRequester.ClientID %>').tryLock(id, 3600, function() { Navigate(id, clientid) }, function() { __doPostBack('<%= lockResquestFailed.ClientID %>', id) });
                }
                else {
                    selectCurrentNode();
                }
            }

            function Navigate(id, clientId, node)
            {
                $find('<%= MedianamikFormTemplate.LockActivator.ClientID %>').set_lockStopped(true);
                Medianamik.UI.Services.LockWebService.Unlock(nodeId);
                if (node && node.get_expandMode() == 1)
                {
                    var isNavigating = $get(clientId);
                    isNavigating.value = id;
                    node.expand();
                }
                else
                {
                    __doPostBack(clientId, id);
                }
            }
            //]]>
        </script>
    </telerik:RadScriptBlock>
</asp:Content>